﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;

namespace MapReduceLib.DataModel
{
    [DataContract]
    public class Job
    {
        private string jobId;
        private string jobName;
        private string jobVersion;
        private byte[] assemblyBytes;
        private string assemblyFileName;
        private List<string> userParameters;
        private DataSource dataSource;

        public Job()
        {
            userParameters = new List<string>();
        }

        [DataMember(IsRequired = false, Order = 0)]
        public string JobId
        {
            get { return jobId; }
            set { jobId = value; }
        }

        [DataMember(Order = 0)]
        public string JobName
        {
            get { return jobName; }
            set { jobName = value; }
        }

        [DataMember(Order = 0)]
        public string JobVersion
        {
            get { return jobVersion; }
            set { jobVersion = value; }
        }

        public byte[] AssemblyBytes
        {
            get { return assemblyBytes; }
            set { assemblyBytes = value; }
        }

        [DataMember(Order = 0)]
        public string AssemblyFileName
        {
            get { return assemblyFileName; }
            set { assemblyFileName = value; }
        }

        [DataMember(Order = 0)]
        public List<string> UserParameters
        {
            get { return userParameters; }
            set { userParameters = value; }
        }

        [DataMember(Order = 0)]
        public DataSource DataSource
        {
            get { return dataSource; }
            set { dataSource = value; }
        }

        [OnDeserialized]
        public void OnDeserialized(StreamingContext context)
        {
            if (userParameters == null)
                userParameters = new List<string>();
        }
    }
}
